function getRandomPosts(json) {
var numPosts = json.feed.openSearch$totalResults.$t;
var indexPosts = new Array();
    var img  = new Array();
   
for (var i = 0; i < numPosts; ++i) {
indexPosts[i] = i;
}
indexPosts.sort(function() {return 0.5 - Math.random()});
if (maxEntries > numPosts) {
maxEntries = numPosts;
}

var container = document.getElementById('random-posts');
var ul = document.createElement('ul');
for (i = 0; i < maxEntries; ++i) {
var entry = json.feed.entry[indexPosts[i]];

for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'replies' && entry.link[k].type == 'text/html') {
pcm = entry.link[k].title.split(" ")[0];
break;
}
}

postdate = entry.published.$t;
var month = [1,2,3,4,5,6,7,8,9,10,11,12];
        var month2 = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];

        var day = postdate.split("-")[2].substring(0,2);
        var m = postdate.split("-")[1];
        var y = postdate.split("-")[0];

        for(var u2=0;u2<month.length;u2++){
                if(parseInt(m)==month[u2]) {
                        m = month2[u2] ; break;
                }
        }
if (pcm==0) {var comment = " (" +nocmtext+ ") ";}
else {var comment = " (" + pcm + " " +cmtext+ ") ";}

var comment0 = "<br/>" +comment + "";

var s = entry.content.$t;
var a=s.indexOf("<img");
var b=s.indexOf("src=\"",a);
var c=s.indexOf("\"",b+5);
var d=s.substr(b+5,c-b-5);
var li = document.createElement('li');
if (i==0) { li.id = 'li-rd'; }
if ((i%2==0)&&(i!=0)) {li.id = 'li-rd-chan';}
if (i%2==1) {li.id = 'li-rd-le';}

var img = document.createElement('img');
if (i==0) { img.id = 'rd-thumb0'; }
else { img.id = 'rd-thumb'; }

if((a!=-1)&&(b!=-1)&&(c!=-1)&&(d!=""))
{img.src = d;}
else
{ img.src="";}

var em = document.createElement('i');
if (i==0) { em.innerHTML = comment0; }
else { em.innerHTML = comment; }


var a = document.createElement('a');

a.title = entry.title.$t;
for (var j = 0; j < entry.link.length; ++j) {
if (entry.link[j].rel == 'alternate') {
a.href = entry.link[j].href;
break;
}
}
a.appendChild(document.createTextNode(entry.title.$t));
li.appendChild(img);
li.appendChild(a);
li.appendChild(em);
ul.appendChild(li);

}
container.appendChild(ul);
document.getElementById("rd-posts-loading").style.display = "none";
}